﻿Imports System.Collections.Generic
Imports Pop.Api.Response
Imports Pop.Api.Util

Namespace Pop.Api.Request
    ''' <summary>
    ''' 1.06 (初级)批量修改商品状态(上下架)
    ''' </summary>
    Public Class ModifyItemStateRequest
        Inherits PopRequest(Of ModifyItemStateResponse)

        ''' <summary>
        ''' 卖家QQ号
        ''' </summary>
        Property SellerUin As Nullable(Of Long)

        ''' <summary>
        ''' 商品编码,多个用半角逗号分隔,最多20个(支持多次出现!)
        ''' </summary>
        Property ItemCode As String

        ''' <summary>
        ''' 商品私有编码,多个用半角逗号分隔,最多20个(支持多次出现!)
        ''' </summary>
        Property ItemLocalCode As String

        ''' <summary>
        ''' 是否上架
        ''' IS_FOR_SALE：上架销售。
        ''' IS_IN_STORE：放入仓库。
        ''' </summary>
        Property ItemState As String

#Region "Overrides"

        Protected Overrides Function GetApiName() As String
            Return "item.modifyItemState"
        End Function

        Protected Overrides Function GetParameters() As IEnumerable(Of KeyValuePair(Of String, String))
            Dim parameters As New PopDictionary
            parameters.Add("sellerUin", Me.SellerUin)
            If Me.ItemCode IsNot Nothing AndAlso Not String.IsNullOrEmpty(Me.ItemCode) Then
                For Each Code In Me.ItemCode.Split({","c}, StringSplitOptions.RemoveEmptyEntries)
                    parameters.Add("itemCode", Code)
                Next
            End If
            If Me.ItemLocalCode IsNot Nothing AndAlso Not String.IsNullOrEmpty(Me.ItemLocalCode) Then
                For Each LocalCode In Me.ItemLocalCode.Split({","c}, StringSplitOptions.RemoveEmptyEntries)
                    parameters.Add("itemLocalCode", LocalCode)
                Next
            End If
            parameters.Add("itemState", Me.ItemState)
            Return parameters
        End Function

        Protected Overrides Sub Validate()
            Me.SellerUin.ValidateRequired("SellerUin")
            Me.ItemCode.ValidateMaxListSize("ItemCode", 20)
            Me.ItemLocalCode.ValidateMaxListSize("ItemLocalCode", 20)
        End Sub

#End Region

    End Class
End Namespace